package Pantallas;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import Clases.*;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class aEstu extends javax.swing.JDialog {
	Seccion sec;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JLabel jLabel5;
	private JPanel jPanel1;
	private JTextField jTextField2;
	private JLabel jLabel2;
	private JTextField jTextField1;
	private JLabel jLabel1;
	private JTextField jTextField3;
	private JButton jButton2;
	private JButton jButton4;

	/**
	* Auto-generated main method to display this JDialog
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrame frame = new JFrame();
				aEstu inst = new aEstu(frame);
				inst.setVisible(true);
			}
		});
	}
	
	public aEstu(JFrame frame) {
		super(frame);
		initGUI();
	}
	public aEstu(JFrame frame,Seccion sec) {
		super(frame);
		this.sec=sec;
		initGUI();
	}
	Seccion getSeccion()
	{
		return sec;
	}
	private void initGUI() {
		try {
			{
				getContentPane().setLayout(null);
				{
					jButton4 = new JButton();
					getContentPane().add(jButton4);
					jButton4.setText("Volver");
					jButton4.setBounds(208, 224, 119, 22);
					jButton4.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagenes/icono-flecha-izq.gif.png")));
					jButton4.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButton4.actionPerformed, event="+evt);
							//TODO add your code for jButton4.actionPerformed
							dispose();
						}
					});
				}
				{
					jButton2 = new JButton();
					getContentPane().add(jButton2);
					jButton2.setText("Aceptar");
					jButton2.setBounds(61, 224, 119, 22);
					jButton2.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagenes/icon_accept.gif")));
					jButton2.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButton2.actionPerformed, event="+evt);
							//TODO add your code for jButton2.actionPerformed
							String ced = jTextField1.getText();
							String nom = jTextField2.getText();
							String ape = jTextField3.getText();
							Estudiante es = new Estudiante(ced,nom,ape);
							sec.IncluirEstudiante(es);
							jTextField1.setText(null);
							jTextField2.setText(null);
							jTextField3.setText(null);
							
						}
					});
				}
				{
					jTextField3 = new JTextField();
					getContentPane().add(jTextField3);
					jTextField3.setBounds(159, 159, 161, 22);
					jTextField3.setFont(new java.awt.Font("Dialog",0,12));
					jTextField3.addKeyListener(new KeyAdapter() {
						public void keyReleased(KeyEvent evt) {
							System.out.println("jTextField3.keyReleased, event="+evt);
							Validador val = new Validador();
							if (!val.validarLetra(evt))
							{
								jTextField3.setText("");
								JOptionPane.showMessageDialog(null, "Dato Invalido");
							}
							//TODO add your code for jTextField3.keyReleased
						}
					});
				}
				{
					jLabel3 = new JLabel();
					getContentPane().add(jLabel3);
					jLabel3.setText("Apellido:");
					jLabel3.setBounds(41, 162, 68, 15);
					jLabel3.setFont(new java.awt.Font("Dialog",0,12));
				}
				{
					jLabel1 = new JLabel();
					getContentPane().add(jLabel1);
					jLabel1.setText("Cedula:");
					jLabel1.setBounds(41, 93, 59, 15);
					jLabel1.setFont(new java.awt.Font("Dialog",0,12));
				}
				{
					jTextField1 = new JTextField();
					getContentPane().add(jTextField1);
					jTextField1.setBounds(159, 89, 161, 24);
					jTextField1.setFont(new java.awt.Font("Dialog",0,12));
					jTextField1.addKeyListener(new KeyAdapter() {
						public void keyReleased(KeyEvent evt) {
							System.out.println("jTextField1.keyReleased, event="+evt);
							Validador val = new Validador();
							if (!val.validarNumero(evt))
							{
								jTextField1.setText("");
								JOptionPane.showMessageDialog(null, "Cedula Invalida");
							}
							//TODO add your code for jTextField1.keyReleased
						}
					});
				}
				{
					jLabel2 = new JLabel();
					getContentPane().add(jLabel2);
					jLabel2.setText("Nombre:");
					jLabel2.setBounds(41, 125, 66, 15);
					jLabel2.setFont(new java.awt.Font("Dialog",0,12));
				}
				{
					jTextField2 = new JTextField();
					getContentPane().add(jTextField2);
					jTextField2.setBounds(159, 123, 161, 22);
					jTextField2.setFont(new java.awt.Font("Dialog",0,12));
					jTextField2.addKeyListener(new KeyAdapter() {
						public void keyReleased(KeyEvent evt) {
							System.out.println("jTextField2.keyReleased, event="+evt);
							Validador val = new Validador();
							if (!val.validarLetra(evt))
							{
								jTextField2.setText("");
								JOptionPane.showMessageDialog(null, "Dato Invalido");
							}
							//TODO add your code for jTextField2.keyReleased
						}
					});
				}
				{
					jLabel4 = new JLabel();
					getContentPane().add(jLabel4);
					jLabel4.setText("Datos del Estudiante");
					jLabel4.setBounds(80, 30, 185, 27);
					jLabel4.setFont(new java.awt.Font("Dialog",1,18));
				}
				{
					jPanel1 = new JPanel();
					getContentPane().add(jPanel1);
					jPanel1.setBounds(23, 77, 344, 125);
					jPanel1.setBorder(BorderFactory.createTitledBorder(""));
				}
				{
					jLabel5 = new JLabel();
					getContentPane().add(jLabel5);
					jLabel5.setBounds(299, 18, 63, 59);
					jLabel5.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagenes/iconEstudiante.gif")));
				}
			}
			this.setSize(400, 301);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
